package com.etocrm.saas.lib.base.common.exception;

import com.etocrm.saas.lib.base.common.result.IResultCode;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 基类异常
 */
@Slf4j
@Getter
abstract public class BaseException extends RuntimeException {

    /**
     * 异常对应的错误类型
     */
    private Integer code;

    private IResultCode resultCodeEnum;


    protected BaseException(IResultCode resultCode) {
        this(resultCode.getCode(), resultCode.getMessage());
        this.resultCodeEnum = resultCode;
    }

    protected BaseException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return super.getMessage();
    }
}
